<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery.min.js"></script>
    <script>
        $(function () {
            $("#btn2").click(function () {
                $.post("./server/stu.json", function(data){
                    alert("Data Loaded: " + data.name + data.age);
                },"json");
            });
            $("#btn3").click(function () {
                $.post("./server/arr.json", function(data){
                    $.each( data, function(i, n){
                        alert( "Item #" + i + ": " + n.c02 );
                    });
                },"json");
            });
            $("#btn4").click(function () {
                $.getJSON("./server/arr.json",function (myjsonobj) {
                    $.each( myjsonobj, function(i, n){
                        alert( "Item #" + i + ": " + n.c02 );
                    });
                });

            });
        })

        var json = {
            contry:{
                area:{
                    man:"12万",
                    women:"10万"
                }
            }
        };
        function show() {
            alert(json.contry.area.man);
        }
        function show2() {
            var strjson="{'name':'aabbcc'}";
            var objjson=new Function("return" + strjson)();

//            Object.defineProperty(objjson, 'name', {
//                writable: false,
//                value: 'Rick'
//            });
            alert(objjson.name);
        }
    </script>
</head>
<body>
<button onclick="show()">测试</button>
<button onclick="show2()">字符串json解析测试</button>
<br>
<button id="btn2">ajax测试2</button>
<button id="btn3">ajax测试数组</button>
<button id="btn4">ajax测试数组</button>
</body>
</html>